<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/commons/pages/taglibs.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>器件管理</title>
<link rel="stylesheet" type="text/css" href="../jquery-easyui/themes/${themes}/easyui.css">
<link rel="stylesheet" type="text/css" href="../jquery-easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../styles/demo.css">
<script type="text/javascript" src="../jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="../jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../commons/scripts/jquery.form.js"></script>
<script type="text/javascript" src="../scripts/public.js.jsp"></script>
<script type="text/javascript" src="${ctx}/platform/type-info/format"></script>
</head>
<body>
<!--div class="demo-info">
  <div class="demo-tip icon-tip"></div>
  <div>器件管理</div>
</div-->
<c:if test="${fn:containsIgnoreCase(action_codes, 'S')}">
  <div style="padding:5px; margin-bottom:5px; display:block;" class="combo">
    <form method="post" id="fm_search" novalidate>
      编码：
      <input type="text" id="part_code" name="part_code" style="width:80px;" />
      名称：
      <input type="text" id="part_name" name="part_name" style="width:80px;" />
      描述：
      <input type="text" id="part_desc" name="part_desc" style="width:80px;" />
      级别：
      <select id="part_level" name="part_level" style="width:80px;">
      </select>
      优选：
      <select id="sel_level" name="sel_level" style="width:80px;">
      </select>
      <br />
      厂家：
      <input type="text" id="factory" name="factory" style="width:80px;" />
      型号：
      <input type="text" id="part_number" name="part_number" style="width:80px;" />
      封装：
      <input type="text" id="footprint" name="footprint" style="width:80px;" />
      删除：
      <select id="is_del" name="is_del" style="width:80px;">
      </select>
      <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="doSearch();">搜索</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="$('#fm_search').form('clear');">重置</a>
    </form>
  </div>
</c:if>
<div id="dg">&nbsp;</div>
<div id="dlg" class="easyui-dialog" data-options="closed:true, modal:true, buttons:'#dlg-buttons'" style="width:540px; height:540px; padding:10px 40px">
  <form method="post" id="fm" novalidate enctype="multipart/form-data">
    <input name="id" type="hidden" id="id" />
    <table>
      <tr>
        <td align="right" width="100"><b>编码：</b></td>
        <td><input type="text" id="part_code" name="part_code" class="easyui-validatebox" data-options="required:true" /></td>
      </tr>
      <tr>
        <td align="right"><b>名称：</b></td>
        <td><input type="text" id="part_name" name="part_name" class="easyui-validatebox" data-options="required:true" /></td>
      </tr>
      <tr>
        <td align="right"><b>级别：</b></td>
        <td><select id="part_level" name="part_level" style="width:80px;" class="easyui-validatebox" data-options="required:true">
          </select></td>
      </tr>
      <tr>
        <td align="right"><b>描述：</b></td>
        <td><input type="text" id="part_desc" name="part_desc" class="easyui-validatebox" style="width:320px" data-options="required:true" /></td>
      </tr>
      <tr>
        <td align="right"><b>制造厂家：</b></td>
        <td><input type="text" id="factory" name="factory" class="easyui-validatebox" style="width:320px" data-options="required:true" /></td>
      </tr>
      <tr>
        <td align="right"><b>厂家型号：</b></td>
        <td><input type="text" id="part_number" name="part_number" class="easyui-validatebox" style="width:320px" data-options="required:true" /></td>
      </tr>
      <tr>
        <td align="right"><b>优选级别：</b></td>
        <td><select id="sel_level" name="sel_level" style="width:80px;" class="easyui-validatebox" data-options="required:true">
          </select></td>
      </tr>
      <!-- 
      <tr>
        <td align="right"><b>创建时间：</b></td>
        <td><input type="text" id="create_time" name="create_time" class="easyui-datetimebox easyui-validatebox" size="20" style="width:140px;" readonly required /></td>
      </tr>
      -->
      <tr>
        <td align="right"><b>封装：</b></td>
        <td><input type="text" id="footprint" name="footprint" class="easyui-validatebox" style="width:320px" data-options="required:true" /></td>
      </tr>
      <tr>
        <td align="right"><b>器件资料：</b></td>
        <td><input type="file" id="part_data_file" name="part_data_file" /></td>
      </tr>
      <tr>
        <td align="right"><b>是否安规产品：</b></td>
        <td><select id="is_safety" name="is_safety" style="width:80px;" class="easyui-validatebox" data-options="required:true">
          </select></td>
      </tr>
      <tr>
        <td align="right"><b>安规资料：</b></td>
        <td><input type="text" id="safety_data" name="safety_data" class="easyui-validatebox" style="width:320px" /></td>
      </tr>
      <tr>
        <td align="right"><b>参考价格：</b></td>
        <td><input type="text" id="price" name="price" class="easyui-numberbox" /></td>
      </tr>
      <tr>
        <td align="right"><b>备注：</b></td>
        <td><input type="text" id="remark" name="remark" class="easyui-validatebox" style="width:320px" /></td>
      </tr>
      <tr>
        <td align="right"><b>删除：</b></td>
        <td><select id="is_del" name="is_del" style="width:80px;" class="easyui-validatebox" data-options="required:true">
          </select></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td><div id="p" class="easyui-progressbar" style="width:320px;display:none;"></div></td>
      </tr>
    </table>
  </form>
</div>
<div id="dlg-buttons"> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="doSave();">保存</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#dlg').dialog('close');">关闭</a> </div>
<script type="text/javascript">
$(function(){
	//初始化列表
	$('#dg').datagrid({  
	    url:'${ctx}/platform/part-info/search',
		queryParams:$('#fm_search').serializeObject(),
	    frozenColumns:[[
	    	{field:'ck',checkbox:true}
	 	]],
	    columns:[[//width:$(this).width() * 0.2
			{field:'id',title:'id',hidden:true},   
	        {field:'part_code',title:'编码'/*,width:60*/,sortable:true},
	        {field:'part_name',title:'名称'/*,width:60*/},
	        {field:'part_level',title:'级别'/*,width:50*/,formatter:formatPart_level,styler:stylePart_level},
	        {field:'part_desc',title:'描述'/*,width:280*/},
			{field:'factory',title:'制造厂家'/*,width:80*/},
			{field:'part_number',title:'厂家型号'/*,width:160*/},
			{field:'footprint',title:'封装'/*,width:60*/},
			{field:'sel_level',title:'优选级别'/*,width:40*/,align:'center'},
			{field:'create_time',title:'创建时间'/*,width:80*/,align:'center'},
			{field:'part_data',title:'器件资料'/*,width:60*/,formatter:function(value){
				var prefix = 'files/upload/';
				if(value && value.substr(0, prefix.length) == prefix){
					return '<a href="${ctx}/' + value + '" target="_blank">下载</a>';
				}
				return '';
			}},
			//{field:'remark',title:'备注'/*,width:100*/},
			{field:'is_safety',title:'安规类器件'/*,width:40*/,align:'center',formatter:formatBoolean,styler:styleBoolean},
			//{field:'safety_data',title:'安规认证资料'/*,width:100*/},
			//{field:'price',title:'参考价格'/*,width:60*/,align:'right'},
			{field:'is_del',title:'删除'/*,width:40*/,align:'center',formatter:formatBoolean,styler:styleBoolean}
	    ]],
		pageSize:10,
		pageList:[10,20,30,40,50,100],
		//fitColumns:true,
		striped:true,
		pagination:true,
		remoteSort:false,
		rownumbers:true,
		singleSelect:false,
		toolbar:[
		//<c:if test="${fn:containsIgnoreCase(action_codes, 'D')}">
		{
			id:'btnRemove',
			text:'删除',
			iconCls:'icon-remove',
			handler:function(){doRemove();}
		},'-',
		//</c:if>
		//<c:if test="${fn:containsIgnoreCase(action_codes, 'C')}">
		{
			id:'btnAdd',
			text:'添加',
			iconCls:'icon-add',
			handler:function(){doAdd();}
		},
		//</c:if>
		//<c:if test="${fn:containsIgnoreCase(action_codes, 'U')}">
		{
			id:'btnEdit',
			text:'修改',
			iconCls:'icon-edit',
			handler:function(){doEdit();}
		},
		//</c:if>
		//<c:if test="${fn:containsIgnoreCase(action_codes, 'E')}">
		{
			id:'btnToExcel',
			text:'导出查询结果到Excel文件',	
			iconCls:'icon-save',
			handler:function(){
				var o = $('#fm_search').serializeObject();
				var condition = 0;
				var condition_min = 2;
				for (var p in o) {
					if (o[p].length > 0) condition++;
				}
				if (condition < condition_min) {
					$.messager.alert(MSG_WARNING, '请先查询您需要的数据（至少 ' + condition_min + ' 个查询条件）后再导出！', 'warning');
					return false;
				}
				var params = decodeURIComponent($("#fm_search").serialize(), true);
				//window.open('${ctx}/platform/part-info/export?' + params); //iframe效果要比window.open好一点点
			    $('<iframe />').hide().attr("src", '${ctx}/platform/part-info/export?' + params).appendTo(document.body);
			}
		}
		//</c:if>
		]
	});  

});
</script>
</body>
</html>